<!DOCTYPE html>
<html>
<link href="resources/flexbox.css" rel="stylesheet">
<style>
.flexbox {
    margin: 120px;
    width: 100px;
    height: 100px;
    background-color: #aaa;
    position: relative;
    outline: 2px solid red;
}
.title {
    margin-bottom: 10px;
}
.flexbox > div {
    height: 110px;
    width: 110px;
}
.flexbox :nth-child(1) {
    background-color: blue;
}
.flexbox :nth-child(2) {
    background-color: green;
}
.ltr {
    direction: ltr;
}
.rtl {
    direction: rtl;
}
.horizontal-tb {
    -webkit-writing-mode: horizontal-tb;
}
.horizontal-bt {
    -webkit-writing-mode: horizontal-bt;
}
.vertical-rl {
    -webkit-writing-mode: vertical-rl;
}
.vertical-lr {
    -webkit-writing-mode: vertical-lr;
}
</style>
<script src="../../resources/check-layout.js"></script>
<body onload="checkLayout('.flexbox')">

<script>
function positionAsString(position)
{
    return 'data-offset-x="' + position[0] + '" data-offset-y="' + position[1] + '"';
}

var expectations = {
    'horizontal-tb': {
        'row': { rtl: [-10, -10], ltr: [0, -10]},
        'row-reverse': { rtl: [0, -10], ltr: [-10, -10]},
        'column': { rtl: [0, 0], ltr: [-10, 0]},
        'column-reverse': { rtl: [0, -10], ltr: [-10, -10]}
    },
    'horizontal-bt': {
        'row': { rtl: [-10, 0], ltr: [0, 0]},
        'row-reverse': { rtl: [0, 0], ltr: [-10, 0]},
        'column': { rtl: [0, -10], ltr: [-10, -10]},
        'column-reverse': { rtl: [0, 0], ltr: [-10, 0]}
    },
    'vertical-lr': {
        'row': { rtl: [-10, -10], ltr: [-10, 0]},
        'row-reverse': { rtl: [-10, 0], ltr: [-10, -10]},
        'column': { rtl: [0, 0], ltr: [0, -10]},
        'column-reverse': { rtl: [-10, 0], ltr: [-10, -10]}
    },
    'vertical-rl': {
        'row': { rtl: [0, -10], ltr: [0, 0]},
        'row-reverse': { rtl: [0, 0], ltr: [0, -10]},
        'column': { rtl: [-10, 0], ltr: [-10, -10]},
        'column-reverse': { rtl: [0, 0], ltr: [0, -10]}
    }
}

var writingModes = ['horizontal-tb', 'horizontal-bt', 'vertical-lr', 'vertical-rl'];
var flexFlows = ['row', 'column', 'row-reverse', 'column-reverse'];
var directions = ['ltr', 'rtl'];

writingModes.forEach(function(writingMode) {
    flexFlows.forEach(function(flexFlow) {
        directions.forEach(function(direction) {
            var flexboxClassName = writingMode + ' ' + direction + ' ' + flexFlow;

            var title = document.createElement('div');
            title.className = 'title';
            title.innerHTML = flexboxClassName;
            document.body.appendChild(title);

            var container = document.createElement('div');
            container.innerHTML = '<div class="flexbox align-items-flex-end ' + flexboxClassName + '">\n' +
                '<div class="flex-none" ' + positionAsString(expectations[writingMode][flexFlow][direction]) + '></div><div class="flex-none"></div>\n' +
            '</div>';

            document.body.appendChild(container);
        })
    })
})
</script>

</body>
</html>
